<?php

class ConfigurationAction extends AdminPublicAction {

    public function index() {
		
		
		
		if (S("success") != "")
		{
			$this->assign("msg", '<div class="success">'.S("success").'</div>');
			S('success',NULL);
		}
		if (S("err") != "")
		{
			$this->assign("msg", '<div class="err">'.S("err").'</div>');
			S('err',NULL);
		}
		//获取所有省份和城市
		$this->allProvince   = M('province')->select();
		$this->allCity   = M('city')->select();
		$this->e_allProvince   = json_encode($this->allProvince);
		$this->e_allCity   = json_encode($this->allCity);
		$this->left_webinfo = 'current';
        $this->display();
		
    }

    /**
      +----------------------------------------------------------
     * 网站配置信息保存操作
      +----------------------------------------------------------
     */
    public function checkSystemConfig($obj = "SITE_INFO") {
        if (IS_POST) {
            $config = CONF_PATH."systemConfig.php";
            $config = file_exists($config) ? include "$config" : array();
            $config = is_array($config) ? $config : array();
            $config = array_merge($config, array("$obj" => $_POST));
            if (F("systemConfig", $config, "./myApp/Conf/")) {
               delDirAndFile(CACHE_PATH."/~runtime.php");
			   S('success','Configuration update successfully!');
			   $this->redirect('index');
            } else {
                S('err','Configuration update failure!');
			   $this->redirect('index');
            }
        } 
    }

}

?>